package #(servicePackage??'').#(package);
import com.duoketech.service.AbstractService;
import com.duoketech.model.#(package).#(modelName??'');
import com.duoketech.exception.ValidateException;
import com.duoketech.utils.search.QueryConstructor;
import com.duoketech.utils.validator.Validator;
import com.duoketech.utils.validator.rules.string.StringLengthBetween;
import com.duoketech.utils.validator.rules.string.StringMustBeRequired;
import com.jfinal.kit.Kv;
import com.jfinal.plugin.activerecord.Model;
import java.util.Map;
public class #(modelName??'')Service extends AbstractService{
    public static #(modelName??'')Service ME = new #(modelName??'')Service();

    @Override
    public void validatorUpdate(Model<?> model, Kv kv) throws ValidateException {
        validatorAdd(model,kv);
    }

    @Override
    public void validatorAdd(Model<?> model, Kv kv) throws ValidateException {

        Validator validator = new Validator();
        #for(x:columns)
        validator.addRule(new StringMustBeRequired(model.getStr(#(modelName??'').#(toUpperCase(x.COLUMN_NAME))),"#(x.COLUMN_COMMENT??'')项为必填信息"));
        validator.addRule(new StringLengthBetween(model.getStr(#(modelName??'').#(toUpperCase(x.COLUMN_NAME))),"#(x.COLUMN_COMMENT??'')项字符必须为1-50个字符",1,50));
        #end
        validator.excute();

    }

    @Override
    public void beforAdd(Model<?> model, Kv kv) throws ValidateException {

    }

    @Override
    public void afterAdd(Model<?> model, Kv kv) throws ValidateException {

    }

    @Override
    public void beforUpdate(Model<?> model, Kv kv) throws ValidateException {

    }

    @Override
    public void afterUpdate(Model<?> model, Kv kv) throws ValidateException {

    }

    @Override
    public void beforQuery(int id, Model<?> model, Kv kv) throws ValidateException {

    }

    @Override
    public void afterQuery(int id, Model<?> model, Kv kv) throws ValidateException {

    }

    @Override
    public void beforDelete(int id, Model<?> model, Kv kv) throws ValidateException {

    }

    @Override
    public void afterDelete(int id, Model<?> model, Kv kv) throws ValidateException {

    }

    @Override
    public String tableName() {
        return #(modelName??'').dao.tableName();
    }

    @Override
    public void builderSQLExpected(Model<?> model, QueryConstructor queryConstruct, Kv kv) {

    }
}
